import SevenDays from "./SevenDays"
import cjs=createjs
import BaseDialogView from "../BaseDialogView"
import Global from "../../../Global"
import SignInButton from "./SignInButton"
import ButtonHelper from "../../../ButtonHelper"
import { TouchEvent, ViewEvent } from "../../../Const"
import LocalData from "../../../LocalData"
//import createjs from "../../../../createjs"

export default class SignInDialogView extends BaseDialogView{
    private days:SevenDays
    //private bt_close:cjs.Bitmap
    private bt_sign:SignInButton
    private _w=700
    private _h=1050
    constructor(){
        super()
        this.days=new SevenDays()
        this.days.setSize(this._w,this._h)
        let rect=this.days.getBounds()
        this.days.setTransform(0,100,1,1,0,0,0,rect.width/2,rect.height/2)
        this.content.addChild(this.days)
        //标题
        const title=new cjs.Bitmap(this.getResource('signin_title'))
        rect=title.getBounds()
        title.setTransform(0,rect.height/2-this._h/2,1,1,0,0,0,rect.width/2,rect.height/2)
        this.content.addChild(title)
        //关闭按钮
        const bt_close=new cjs.Bitmap(this.getResource('signin_close'))
        bt_close.setTransform(this._w/2-100,100-this._h/2,0.8,0.8)
        this.content.addChild(bt_close)
        const btnClose=new ButtonHelper(bt_close)
        btnClose.on(TouchEvent.TOUCH_START,():void=>{this.dispatchEvent('close',true)})
        //this.bt_close=bt_close
        this.reflush()
        //签到按钮
        const label=new cjs.Bitmap(this.getResource('sign_font'))
        this.bt_sign=new SignInButton(label)
        this.bt_sign.setSize(300,84)
        this.bt_sign.setTransform(0,this._h/2,1,1,0,0,0,150,0)
        this.content.addChild(this.bt_sign)
        const btnHelper=new ButtonHelper(this.bt_sign)
        btnHelper.on(TouchEvent.TOUCH_START,():void=>{
            LocalData.getInstance().sign()
            this.dispatchEvent('close',true)
        })
    }
}